<?php 
/****
布尔教育 高端PHP培训
培  训: http://www.itbool.com
论  坛: http://www.zixue.it
****/
require('./lib/init.php');

if(empty($_POST)){
    include(ROOT . '/view/admin/catadd.html');
} else {

	//检测栏目是否为空
	$cat['catname'] = trim($_POST['catname']);
	if (empty($cat['catname'])) {
		error('栏目不能为空');
		exit();
	}
	
	//检测栏目名是否已存在
	$sql = "select count(*) from cat where catname='$cat[catname]'";
    $rs = mQuery($sql);
    //var_dump($rs);exit();
    if(mysqli_fetch_row($rs)[0] !=0){
    	error('栏目已经存在');
    	exit();
    }
    //将栏目写入栏目表
    //$sql = "insert into cat (catname) values ('$cat[catname]')";
    if(!mExec('cat',$cat)){
    	error('栏目插入失败');
    } else {
    	succ('栏目插入成功');
    }
}


?>